package org.bill.type;

public enum ElementType {

    /**
     * 未激活
     */
    NOTACTIVE(0, "未激活"),
    /**
     * 禁用
     */
    DISABLE(1, "禁用"),
    /**
     * 冻结
     */
    FROZEN(2, "冻结"),
    /**
     * 正常
     */
    NORMAL(3, "正常");

    private final int index;
    private final String name;

    private ElementType(int index, String name) {
        this.index = index;
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public int getIndex(String name) {
        int result = 0;
        if (name == null || name.equals("")) {
            return result;
        }

        for (ElementType e : ElementType.values()) {
            if (e.getIndex() == index) {
                result = e.index;
                break;
            }
        }
        return result;
    }

    public String getName() {
        return name;
    }

    public String getName(int index) {
        String result = null;
        if (index < 1) {
            return result;
        }

        for (ElementType e : ElementType.values()) {
            if (e.getIndex() == index) {
                result = e.name;
                break;
            }
        }
        return result;
    }

}
